/**
let reducers = {
    counter1,
    counter2
}
 */

function combineReducers(reducers) {
    //返回一个新的reducer函数
    return function (state = {}, action) {
        let nextState = {};
        for (let key in reducers) {
            //取出key对应的老的分状态
            let prevStateForKey = state[key];
            let reducerForKey = reducers[key];
            let nextStateForKey = reducerForKey(prevStateForKey, action);
            nextState[key] = nextStateForKey;
        }
        return nextState;
    }
}
export default combineReducers;